export default {
    name: "mobileRegister",
    data() {
        return {
            userInfo:{
                name:'',
                company:'',
                phone:'',
                pwd:'',
                sex:"男",
                politicCountenance:"群众",
            }
        }
    },
    created : function() {
    },
    mounted : function() {

    },
    methods: {
        registerFn:function () {
            let _this=this;
            this.userInfo.pwd=$.trim(this.userInfo.pwd);
            this.userInfo.name=$.trim(this.userInfo.name);
            if(!this.userInfo.name){
                this.layer.alert("请输入姓名");
                return;
            }
            let regPhone =/^1[3456789]\d{9}$/;
            if(!regPhone.test(this.userInfo.phone)){
                this.layer.alert("请输入11位正确的手机号");
                return;
            }
            if(this.userInfo.pwd.length<6){
                this.layer.alert("请输入6到18位的密码");
                return;
            }
            var regPaw =/^[0-9a-zA-Z]+$/;
            if(!regPaw.test(this.userInfo.pwd)){
                this.layer.alert("请输入数字、字母，及其组合的密码！");
                return;
            }
            this.$post(url.saveOrUpdateUser, this.userInfo)
                .then((response) => {
                    this.layer.alert("注册成功",function (index) {
                        _this.layer.close(index);
                        _this.$router.push({path: '/mobileLogin'});
                    })
                }).catch(err => {
                console.log(err);
            })
        }
    }
}